package cn.wp.ewallet.common.web.controller;

import cn.wp.common.core.Wp;
import cn.wp.common.core.dto.WpResult;
import cn.wp.ewallet.common.service.PubItemDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 数据字典表-控制层
 * Created by ganjie on 2020/01/09
 */
@RestController
@RequestMapping(Wp.WebContext + "/ewallet/common/pubTypeDict")
@Api(tags = "数据字典表")
public class PubItemDictController {

    @Autowired
    private PubItemDictService pubItemDictService;

    /**
     * 后端已经除以100处理过了
     * @param transFee
     * @param mentionFee
     * @return
     */
    @PostMapping("/modifyHandlingFee")
    @ApiOperation("修改手续费")
    public WpResult modifyHandlingFee(BigDecimal transFee, BigDecimal mentionFee) {
        return pubItemDictService.modifyHandlingFee(transFee, mentionFee);

    }


    /**
     * 根据字典编号修改字典值
     * json:[{itemCode:'xx',itemValue:'1'},{{itemCode:'yy',itemValue:'2'}]
     * @return
     */
    @PostMapping("/modifyItemValueByItemCode")
    @ApiOperation("修改字典配置")
    public WpResult modifyItemValueByItemCode(String json) {
        return pubItemDictService.modifyItemValueByItemCode(json);

    }

    /**
     * 字典表查询
     * @param dicId
     * @return
     */
    @GetMapping("/getPubItemDict")
    @ApiOperation("字典表查询")
    public WpResult getPubItemDict(String dicId){
        return new WpResult().success(pubItemDictService.getPubItemDict(dicId));
    }


    @GetMapping("/getPubItemDictByCode")
    @ApiOperation("根据字典ID和code查询字典值")
    public WpResult getPubItemDictByCode(String dicId, String code){
        return new WpResult().success(pubItemDictService.getPubItemDictByCode(dicId, code));
    }

    @GetMapping("/getTransFee")
    @ApiOperation(value = "获取转账手续费")
    public WpResult getTransFee(BigDecimal amount) {
        return new WpResult().success(pubItemDictService.getTransFee(amount));
    }

    @GetMapping("/getMentionFee")
    @ApiOperation(value = "获取提币手续费")
    public WpResult getMentionFee(BigDecimal amount) {
        return new WpResult().success(pubItemDictService.getMentionFee(amount));
    }


}